package com.kun.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kun.dto.SysDictDataDTO;
import com.kun.dto.SysDictTypeDTO;
import com.kun.entity.SysDictData;
import com.kun.entity.SysDictType;
import com.kun.service.SysDictDataService;
import com.kun.service.SysDictTypeService;
import com.kun.util.ResponseResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author kun.li
 */
@RestController
@RequestMapping("dictData")
@RequiredArgsConstructor
@Tag(name = "字典数据管理")
public class SysDictDataController {

    private final SysDictDataService sysDictDataService;

    @PostMapping("selectPage")
    @Operation(summary = "字典数据分页列表")
    public ResponseResult<Page<SysDictData>> selectPage(@RequestBody SysDictDataDTO sysDictDataDTO) {
        Page<SysDictData> sysParamPage = sysDictDataService.page(Page.of(sysDictDataDTO.getPage(), sysDictDataDTO.getSize()));
        return ResponseResult.success(sysParamPage);
    }

    @PostMapping("save")
    @Operation(summary = "字典数据保存")
    public ResponseResult<Boolean> saveParam(@RequestBody SysDictData sysDictData) {
        return ResponseResult.success(sysDictDataService.save(sysDictData));
    }


    @PostMapping("update")
    @Operation(summary = "字典数据修改")
    public ResponseResult<Boolean> updateParam(@RequestBody SysDictData sysDictData) {
        return ResponseResult.success(sysDictDataService.updateById(sysDictData));
    }

    @DeleteMapping("delete")
    @Operation(summary = "字典数据删除")
    public ResponseResult<Boolean> deleteParam(@RequestBody List<String> ids) {
        return ResponseResult.success(sysDictDataService.removeBatchByIds(ids));
    }


}
